<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;

use OT\DataDictionary;


/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class IndexController extends HomeController
{

    //系统首页
    public function index()
    {
        /*  $api = new \Common\Extend\Api\ApiClient();
          $data =  [];
          $a = $api->credit()->Send('post')->data($data);
          print_r($a);exit;
          exit;*/
        $category = D('Category')->getTree();
        $lists = D('Document')->lists(null);
        $this->assign('category', $category);//栏目
        $this->assign('lists', $lists);//列表
        $this->assign('page', D('Document')->page);//分页


        $this->display();
    }

    /**
     * 花呗支付 同步跳转方法
     * 调用分账方法
     */
    public function huabeiReturnUrl()
    {
        $url = "http://qnm.upslope.cn/admin/test/test";
        $ch = curl_init();
        //设置选项，包括URL
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);

        //执行并获取HTML文档内容
        $output = curl_exec($ch);
        //释放curl句柄
        curl_close($ch);
    }

    /**
     * 支付宝授权列表页
     */
    public function authorization(){
        $uid = I('uid');
        $kbsh_id = I('kbsh_id'); //码商id
        $list = M('shouquan')->select();
        foreach($list as $k => $v){
            $list[$k]['url'] =  "https://openauth.alipay.com/oauth2/appToAppAuth.htm?app_id=" . $v['appid'] . "&redirect_uri=http://qnm.upslope.cn/pay.php&uid=$uid&kbsh_id=$kbsh_id";
        }

        $this->assign('list',$list);
        $this->display();
    }

}